package com.itfreer.demo.configuration;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.itfreer.jwt.UserInfo;
import com.itfreer.power.PowerParameter;
import com.itfreer.power.utils.PasswordEncoder;
import com.itfreer.power.utils.PasswordEncoderImpl;

/**
 * 用户权限配置
 */
@Configuration
public class PowerConfiguration {

	/**
	 * 用户密码
	 * 
	 * @return
	 */
	@Bean(name = "passwordEncoderImpl")
	public PasswordEncoder passwordEncoderImpl() {
		PasswordEncoderImpl config = new PasswordEncoderImpl("SHA1");
		config.setCharacterEncoding("UTF-8");
		return config;
	}

	/**
	 * 用户权限管理的配置
	 * 
	 * @return
	 */
	@Bean(name = "powerParameter")
	public PowerParameter powerParameter() {
		PowerParameter config = new PowerParameter();
		config.setSupportSuperAdmin(true);
		config.setAllUserIsSuperAdmin(true);
		config.setSupportTenant(false);
		return config;
	}

	/**
	 * 超级管理员配置信息
	 */
	@Bean(name = "superAdmin")
	public List<UserInfo> superAdmin() {
		List<UserInfo> result = new ArrayList<>();
		UserInfo config = new UserInfo();
		config.setUserId("admin");
		config.setUserName("管理员");
		config.setTenantID("-1");
		result.add(config);
		
		config = new UserInfo();
		config.setUserId("admin1");
		config.setUserName("管理员1");
		config.setTenantID("-1");
		result.add(config);
		return result;
	}
}